<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Irrlicht 3D Engine: irr::video::IShaderConstantSetCallBack Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Irrlicht 3D Engine
   
   </div>
   
  </td>
  
  
  
   
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
   
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="dynsections.js"></script>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('classirr_1_1video_1_1_i_shader_constant_set_call_back.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">irr::video::IShaderConstantSetCallBack Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="irr::video::IShaderConstantSetCallBack" --><!-- doxytag: inherits="irr::IReferenceCounted" -->
<p>Interface making it possible to set constants for gpu programs every frame.  
 <a href="classirr_1_1video_1_1_i_shader_constant_set_call_back.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_i_shader_constant_set_call_back_8h_source.html">IShaderConstantSetCallBack.h</a>&gt;</code></p>
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
  <img id="dynsection-0-trigger" src="closed.png" alt="+"/> Inheritance diagram for irr::video::IShaderConstantSetCallBack:</div>
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
</div>
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
 <div class="center">
  <img src="classirr_1_1video_1_1_i_shader_constant_set_call_back.png" usemap="#irr::video::IShaderConstantSetCallBack_map" alt=""/>
  <map id="irr::video::IShaderConstantSetCallBack_map" name="irr::video::IShaderConstantSetCallBack_map">
<area href="classirr_1_1_i_reference_counted.html" title="Base class of most objects of the Irrlicht Engine." alt="irr::IReferenceCounted" shape="rect" coords="0,0,229,24"/>
</map>
 </div></div>

<p><a href="classirr_1_1video_1_1_i_shader_constant_set_call_back-members.html">List of all members.</a></p>
<h2><a name="pub-methods"></a>
Public Member Functions</h2>
<ul>
<li>virtual void <a class="el" href="classirr_1_1video_1_1_i_shader_constant_set_call_back.html#a91cf4eb8d20d278defaca4e3c9390396">OnSetConstants</a> (<a class="el" href="classirr_1_1video_1_1_i_material_renderer_services.html">IMaterialRendererServices</a> *services, <a class="el" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6">s32</a> userData)=0
<dl class="el"><dd class="mdescRight">Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set.  <a href="#a91cf4eb8d20d278defaca4e3c9390396"></a><br/></dl><li>virtual void <a class="el" href="classirr_1_1video_1_1_i_shader_constant_set_call_back.html#a837ad9419ca4c17b011af75bb24e7a72">OnSetMaterial</a> (const <a class="el" href="classirr_1_1video_1_1_s_material.html">SMaterial</a> &amp;material)
<dl class="el"><dd class="mdescRight">Called to let the callBack know the used material (optional method)  <a href="#a837ad9419ca4c17b011af75bb24e7a72"></a><br/></dl></ul>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Interface making it possible to set constants for gpu programs every frame. </p>
<p>Implement this interface in an own class and pass a pointer to it to one of the methods in <a class="el" href="classirr_1_1video_1_1_i_g_p_u_programming_services.html" title="Interface making it possible to create and use programs running on the GPU.">IGPUProgrammingServices</a> when creating a shader. The OnSetConstants method will be called every frame now. </p>

<p>Definition at line <a class="el" href="_i_shader_constant_set_call_back_8h_source.html#l00021">21</a> of file <a class="el" href="_i_shader_constant_set_call_back_8h_source.html">IShaderConstantSetCallBack.h</a>.</p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a91cf4eb8d20d278defaca4e3c9390396"></a><!-- doxytag: member="irr::video::IShaderConstantSetCallBack::OnSetConstants" ref="a91cf4eb8d20d278defaca4e3c9390396" args="(IMaterialRendererServices *services, s32 userData)=0" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void irr::video::IShaderConstantSetCallBack::OnSetConstants </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classirr_1_1video_1_1_i_material_renderer_services.html">IMaterialRendererServices</a> *&#160;</td>
          <td class="paramname"><em>services</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6">s32</a>&#160;</td>
          <td class="paramname"><em>userData</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [pure virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set. </p>
<p>Implement the <a class="el" href="classirr_1_1video_1_1_i_shader_constant_set_call_back.html" title="Interface making it possible to set constants for gpu programs every frame.">IShaderConstantSetCallBack</a> in an own class and implement your own OnSetConstants method using the given <a class="el" href="classirr_1_1video_1_1_i_material_renderer_services.html" title="Interface providing some methods for changing advanced, internal states of a IVideoDriver.">IMaterialRendererServices</a> interface. Pass a pointer to this class to one of the methods in <a class="el" href="classirr_1_1video_1_1_i_g_p_u_programming_services.html" title="Interface making it possible to create and use programs running on the GPU.">IGPUProgrammingServices</a> when creating a shader. The OnSetConstants method will now be called every time before geometry is being drawn using your shader material. A sample implementation would look like this: </p>
<div class="fragment"><pre class="fragment">    <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classirr_1_1video_1_1_i_shader_constant_set_call_back.html#a91cf4eb8d20d278defaca4e3c9390396" title="Called by the engine when the vertex and/or pixel shader constants for an material renderer should be...">OnSetConstants</a>(video::IMaterialRendererServices* services, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> userData)
    {
        video::IVideoDriver* driver = services-&gt;getVideoDriver();

        <span class="comment">// set clip matrix at register 4</span>
        <a class="code" href="namespaceirr_1_1core.html#a73fa92e638c5ca97efd72da307cc9b65" title="Typedef for f32 matrix.">core::matrix4</a> worldViewProj(driver-&gt;getTransform(<a class="code" href="namespaceirr_1_1video.html#a15b57657a320243be03ae6f66fcff43dae7ec186418508c67a7562af012d7b63f" title="Projection transformation.">video::ETS_PROJECTION</a>));
        worldViewProj *= driver-&gt;getTransform(<a class="code" href="namespaceirr_1_1video.html#a15b57657a320243be03ae6f66fcff43da152f4262d5874186e0288934c7d31e14" title="View transformation.">video::ETS_VIEW</a>);
        worldViewProj *= driver-&gt;getTransform(<a class="code" href="namespaceirr_1_1video.html#a15b57657a320243be03ae6f66fcff43da843cf42adb3fa9caf61c9e228cf14e85" title="World transformation.">video::ETS_WORLD</a>);
        services-&gt;setVertexShaderConstant(&amp;worldViewProj.M[0], 4, 4);
        <span class="comment">// for high level shading languages, this would be another solution:</span>
        <span class="comment">//services-&gt;setVertexShaderConstant(&quot;mWorldViewProj&quot;, worldViewProj.M, 16);</span>

        <span class="comment">// set some light color at register 9</span>
        video::SColorf col(0.0f,1.0f,1.0f,0.0f);
        services-&gt;setVertexShaderConstant(reinterpret_cast&lt;const f32*&gt;(&amp;col), 9, 1);
        <span class="comment">// for high level shading languages, this would be another solution:</span>
        <span class="comment">//services-&gt;setVertexShaderConstant(&quot;myColor&quot;, reinterpret_cast&lt;f32*&gt;(&amp;col), 4);</span>
    }
</pre></div> <dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">services,:</td><td>Pointer to an interface providing methods to set the constants for the shader. </td></tr>
    <tr><td class="paramname">userData,:</td><td>Userdata int which can be specified when creating the shader. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a837ad9419ca4c17b011af75bb24e7a72"></a><!-- doxytag: member="irr::video::IShaderConstantSetCallBack::OnSetMaterial" ref="a837ad9419ca4c17b011af75bb24e7a72" args="(const SMaterial &amp;material)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">virtual void irr::video::IShaderConstantSetCallBack::OnSetMaterial </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classirr_1_1video_1_1_s_material.html">SMaterial</a> &amp;&#160;</td>
          <td class="paramname"><em>material</em></td><td>)</td>
          <td><code> [inline, virtual]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Called to let the callBack know the used material (optional method) </p>
<div class="fragment"><pre class="fragment">    <span class="keyword">class </span>MyCallBack : <span class="keyword">public</span> IShaderConstantSetCallBack
    {
        <span class="keyword">const</span> video::SMaterial *UsedMaterial;

        <a class="code" href="classirr_1_1video_1_1_i_shader_constant_set_call_back.html#a837ad9419ca4c17b011af75bb24e7a72" title="Called to let the callBack know the used material (optional method)">OnSetMaterial</a>(<span class="keyword">const</span> video::SMaterial&amp; material)
        {
            UsedMaterial=&amp;material;
        }

        <a class="code" href="classirr_1_1video_1_1_i_shader_constant_set_call_back.html#a91cf4eb8d20d278defaca4e3c9390396" title="Called by the engine when the vertex and/or pixel shader constants for an material renderer should be...">OnSetConstants</a>(IMaterialRendererServices* services, <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> userData)
        {
            services-&gt;setVertexShaderConstant(<span class="stringliteral">&quot;myColor&quot;</span>, reinterpret_cast&lt;f32*&gt;(&amp;UsedMaterial-&gt;color), 4);
        }
    }
</pre></div> 
<p>Definition at line <a class="el" href="_i_shader_constant_set_call_back_8h_source.html#l00044">44</a> of file <a class="el" href="_i_shader_constant_set_call_back_8h_source.html">IShaderConstantSetCallBack.h</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="_i_shader_constant_set_call_back_8h_source.html">IShaderConstantSetCallBack.h</a></li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="namespaceirr.html">irr</a>      </li>
      <li class="navelem"><a class="el" href="namespaceirr_1_1video.html">video</a>      </li>
      <li class="navelem"><a class="el" href="classirr_1_1video_1_1_i_shader_constant_set_call_back.html">IShaderConstantSetCallBack</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">
<a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht 
Engine</a> Documentation &copy; 2003-2012 by Nikolaus Gebhardt. Generated on Sat Jul 9 2016 18:18:44 for Irrlicht 3D Engine by
<a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
